<%@ include file="../../common/taglibs.jsp"%>
<title><fmt:message key="approve1.title"/></title>
<%
response.setHeader("Cache-Control","no-cache"); // HTTP 1.1
response.setHeader("Pragma","no-cache"); // HTTP 1.0
response.setHeader("Cache-Control", "no-cache,no-store,must-revalidate");
response.setDateHeader ("Expires", -1); // Prevents caching at the proxy server
%>
  <script>
function formatPhone(iForm){
	var form = iForm.form;
    var businessPhoneString = form.businessPhone.value;
    //look in global.js for stripAndFormat() function
    var phone=stripAndFormat(businessPhoneString);
    if(phone != null){
    	form.businessPhone.value = phone;
    	return true;
    }else{
    	return false;
    }
}
</script>
<spring:bind path="associatorView.*">
    <c:if test="${not empty status.errorMessages}">
    <div class="error">
        <c:forEach var="error" items="${status.errorMessages}">
            <img src="<c:url value="/images/iconWarning.gif"/>"
                alt="<fmt:message key="icon.warning"/>" class="icon"/>
		<c:out value="${error}" escapeXml="false"/><br />
		</c:forEach>
    </div>
    </c:if>
</spring:bind>
<%-- set as a variable so the buttons can be used at the top and bottom of the form --%>
<c:set var="buttons">
    <input type="submit" class="button" name="_target1" onclick="bCancel=false" value="<fmt:message key="button.find.establishment"/>"/>
    <input type="submit" class="button" name="_cancel" onclick="bCancel=true" value="<fmt:message key="button.cancel"/>"/>
</c:set>
<label><fmt:message key="approve1.text"/></label><br>
<fieldset>
<legend><fmt:message key="approve1.business.details"/></legend>
<%@ include file="initialBusinessTable.inc"%>
</fieldset>

<hr class="hrGray"/>
<fieldset>
<legend><fmt:message key="approve1.select.text"/></legend>
<form:form method="post" commandName="associatorView" action="associateForm.html?tab=pendingComplaints" onsubmit="return validateBusiness(this)">
<form:hidden path="business.id" />
<input type="hidden" name="page" value="0" />
<table border="0">  
<tr><td>
	<form:errors path="business.businessName" cssClass="fieldError"/>
	<form:checkbox id="checkBusinessName" path="checkBusinessName" value="true"/>
</td>
<td align="right">
    <label for="business.businessName"><fmt:message key="business.name"/>:</label>
    <form:select id="businessMatchMode" multiple="false" path="businessMatchMode">
	<form:options items="${wildcards}" itemLabel="value" itemValue="id"/>
    </form:select>
</td>
<td>
    <form:input path="business.businessName" id="businessName"/>
</td>
</tr>
<tr><td>
	<form:errors path="business.address.address1" cssClass="fieldError"/>
    <form:checkbox id="checkBusinessAddress1" path="checkBusinessAddress1" value="true"/>
</td>
<td align="right">
    <label for="business.address.address1" class="required"><fmt:message key="business.address"/>:</label>
    <form:select id="addressMatchMode" multiple="false" path="addressMatchMode">
    	<form:options items="${wildcards}" itemLabel="value" itemValue="id"/>
    </form:select>
</td>
<td>
  	<form:input path="business.address.address1" id="businessAddress1"/>
</td>
</tr>
<tr><td>
    <form:errors path="business.address.address2" cssClass="fieldError"/>
    <form:checkbox id="checkBusinessAddress2" path="checkBusinessAddress2" value="true"/>
</td>
<td align="right">    
    <label for="business.address.address2" class="required"><fmt:message key="business.address2"/>:</label>
</td>
<td>
  	<form:input path="business.address.address2" id="businessAddress2"/>
</td>
</tr>
<tr><td>
    <form:errors path="business.address.city" cssClass="fieldError"/>
    <form:checkbox id="checkBusinessCity" path="checkBusinessCity" value="true"/>
</td>
<td align="right"> 
    <label for="business.address.city" class="required"><fmt:message key="business.city"/>:</label>
</td>
<td> 
  	<form:input path="business.address.city" id="businessCity"/>
</td>
</tr>
<tr><td>&nbsp;
    <form:errors path="countyId" cssClass="fieldError"/>
</td>
<td align="right"><label for="countyId"><fmt:message key="business.county"/>:</label>
</td>
<td align="right"> 
	    <form:select id="countyId" multiple="false" path="countyId">
	    <form:options items="${sessionScope.countyList}" itemLabel="value" itemValue="id"/>
	    </form:select>
</td>
</tr>
<tr><td>
    <form:errors path="business.address.postalCode" cssClass="fieldError"/>
    <form:checkbox id="checkBusinessZip" path="checkBusinessZip" value="true"/>
</td>
<td align="right">
    <label for=".address.postalCode" class="required"><fmt:message key="business.zip"/>:</label>
</td>
<td>
  	<form:input path="business.address.postalCode" id="businessZip"/>
</td>
</tr>
<tr><td>   
    <form:errors path="business.businessPhone" cssClass="fieldError"/>
    <form:checkbox id="checkBusinessPhone" path="checkBusinessPhone" value="true"/>
</td>
<td align="right">
    <label for="business.businessPhone"><fmt:message key="business.phone"/>:</label>
</td>
<td>
    <form:input path="business.businessPhone" id="businessPhone"  onblur="return formatPhone(this);"/>
</td>
</tr>
</table>
<li class="buttonBar">
    <c:out value="${buttons}" escapeXml="false"/>
</li>
</form:form>
</fieldset>
<hr class="hrGray"/>
